home *** CD-ROM | disk | FTP | other *** search
/ Almathera Ten Pack 3: CDPD 3 / Almathera Ten on Ten - Disc 3: CDPD3.iso / fish / 001-100 / 001-025 / 014 / amiga3d / deallocate.c < prev    next >
C/C++ Source or Header  |  1995-03-17  |  3KB  |  119 lines

  1. #include <exec/types.h>
  2. #include <exec/nodes.h>
  3. #include <exec/lists.h>
  4. #include <exec/memory.h>
  5. #include <hardware/blit.h>
  6. #include <hardware/custom.h>
  7. #include <graphics/gfx.h>
  8. #include <graphics/clip.h>
  9. #include <graphics/rastport.h>
  10. #include <graphics/view.h>
  11. #include <graphics/text.h>
  12. #include <graphics/gfxmacros.h>
  13.  
  14. #include <graphics/layers.h>
  15. #include <intuition/intuition.h>
  16. #include "threed.h"
  17.  
  18. /* #define DEBUG */
  19. /* #define ODEBUG */
  20. /* #define DEBUGDRAW */
  21. /* #define TICKDEBUG */
  22. /* #define TICKPRINT */
  23. #define FIXEDILLUMINATION
  24. #define CYCLECOLORS
  25.  
  26. #ifndef FIXEDILLUMINATION
  27.  
  28. extern UWORD colorpalette[];
  29.  
  30. #else
  31.  
  32. extern UWORD colorpalette[];
  33.  
  34. #endif
  35.  
  36. extern UBYTE title[];
  37.  
  38. extern struct Custom custom;
  39.  
  40. extern struct TmpRas tmpras;
  41.  
  42. extern struct BitMap bitmap0;
  43. extern struct BitMap bitmap1;
  44.  
  45. extern struct RastPort r[];
  46. extern struct RastPort *rp[];
  47.  
  48. extern struct RasInfo ri[];
  49. extern struct RasInfo *rip[];
  50.  
  51. extern struct RasInfo *irip;
  52.  
  53. extern WORD pcount;
  54. extern WORD vcount;
  55.  
  56. extern UWORD frametoggle;
  57.  
  58. extern long GfxBase;
  59.  
  60. /******************************************************************************/
  61.  
  62. objectdeallocate(view,screen,window,objectinfo)
  63. struct View *view;
  64. struct Screen *screen;
  65. struct Window *window;
  66. struct Objectinfo *objectinfo;
  67. {
  68.  
  69.  
  70.    if (objectinfo->displaymatrix)
  71.      FreeMem(objectinfo->displaymatrix,sizeof(struct UV));
  72.  
  73.    if (objectinfo->displayposition)
  74.      FreeMem(objectinfo->displayposition,sizeof(struct Coordinate));
  75.  
  76.    if ((objectinfo->objectbufpoints) && (objectinfo->objectbufpointsize))
  77.      FreeMem(objectinfo->objectbufpoints,objectinfo->objectbufpointsize);
  78.  
  79.    if ((objectinfo->objectbufnormals) && (objectinfo->objectbufnormalsize))
  80.      FreeMem(objectinfo->objectbufnormals,objectinfo->objectbufnormalsize);
  81.  
  82.    /* deallocate buffers for pptr, ntpr, color lists */
  83.  
  84.    if ((objectinfo->pptrbuf) && (objectinfo->pptrbufsize))
  85.      FreeMem(objectinfo->pptrbuf,objectinfo->pptrbufsize);
  86.  
  87.    if ((objectinfo->nptrbuf) && (objectinfo->nptrbufsize))
  88.      FreeMem(objectinfo->nptrbuf,objectinfo->nptrbufsize);
  89.  
  90.    if ((objectinfo->colorbuf) && (objectinfo->colorbufsize))
  91.      FreeMem(objectinfo->colorbuf,objectinfo->colorbufsize);
  92.  
  93.    /* deallocate all subobjects dependent on this object */
  94.  
  95.    while( objectinfo->subobjectinfo )
  96.    {
  97.        struct Objectinfo *soip;
  98.  
  99.        /* delink the first subobjectinfo from the objectinfo list */
  100.  
  101.        soip = objectinfo->subobjectinfo;
  102.  
  103.        objectinfo->subobjectinfo = objectinfo->subobjectinfo->nextobjectinfo;
  104.  
  105.        /* deallocate the buffers dependent on the current subobjectinfo */
  106.  
  107. #ifdef ODEBUG
  108.        printf("    deallocate subobjectinfo(%lx)\n",soip);
  109. #endif
  110.  
  111.        objectdeallocate(view,screen,window,soip);
  112.  
  113.        /* deallocate this subobjectinfo structure itself */
  114.  
  115.        FreeMem(soip,sizeof(struct Objectinfo));
  116.    }
  117.  
  118. }
  119.